/* @(#)GSLoginAction.java    
 *
 * Project: BUS
 *
 * Modify Information:
 * =============================================================================
 *   Author       Date       Description
 *   ------------ ---------- ---------------------------------------------------
 *   Simonyi Peng 2006-2-16    建立
 *
 * Copyright Notice:
 * =============================================================================
 *    Copyright (c) 2001-2006 Beijing HiTRUST Technology Co., Ltd. 1808 Room, 
 *        Science & Technology Building, No. 9 South Street, Zhong Guan Cun, 
 *        Haidian District, Beijing ,100081, China All rights reserved.
 *
 *    This software is the confidential and proprietary information of
 *        Beijing HiTRUST Technology Co., Ltd. ("Confidential Information").
 *        You shall not disclose such Confidential Information and shall use it
 *        only in accordance with the terms of the license agreement you entered
 *        into with HiTRUST.
 *
 * Warning:
 * =============================================================================
 * 
 */
package com.hitrust.gs.action;


import system.LoginContext;

import com.hitrust.gs.bean.GSManufactureBean;
import com.hitrust.gs.bean.GSOrderAnaDetailAndCategoryBean;
import com.hitrust.gs.bean.GSProviderBean;
import com.hitrust.gs.dao.GSManufactureDAO;
import com.hitrust.gs.dao.GSOrderDetailDAO;
import com.hitrust.gs.dao.GSProviderDAO;
import com.hitrust.gs.lib.GSBaseConstants;
import com.hitrust.gs.service.GSBaseAction;
import com.hitrust.gs.service.GSBaseForm;

public class GSOrderGoodsConfirmSaveAction extends GSBaseAction {
	public String execute(GSBaseForm aForm) throws Exception {
		GSManufactureDAO dao = new GSManufactureDAO();

		String manufactureId = aForm.getRequest().getParameter(
				"manufactureid");
        String status = aForm.getRequest().getParameter("status");   
        String remark = aForm.getRequest().getParameter("remark");  
        String currentCount = aForm.getRequest().getParameter("currentCount");  
        String allCount = aForm.getRequest().getParameter("allCount");  
        String isOkCount = aForm.getRequest().getParameter("isOkCount");  
        double sum=Double.parseDouble(currentCount)+Double.parseDouble(isOkCount);
		LoginContext context = (LoginContext) aForm.getSession().getAttribute(
				GSBaseConstants.LOGIN);
	   	GSOrderDetailDAO detailDao=new GSOrderDetailDAO();
	   	GSProviderDAO providerDao=new GSProviderDAO();
	    GSOrderAnaDetailAndCategoryBean orderDetail = detailDao.getOrderDetailByDetailId(manufactureId);
		GSManufactureBean bean=dao.getManufactureByConcentricityCode(orderDetail.getGs_concentricity_id());
		GSProviderBean provider=providerDao.queryProvider(orderDetail.getGs_provider_id());
		
        if("Y".equals(status)){
        	dao.updateOrderGoods(GSBaseConstants.ORDER_DELIVERY_CONFIRM, new framework.core.DateUtil().getDateString(),
        			new framework.core.DateUtil().getTimeString(),allCount,context.getLoginUserName(), remark, manufactureId);
        	dao.insertOrderDetailSignIn(new framework.core.DateUtil().getDateString(), new framework.core.DateUtil().getTimeString(),
        			allCount, currentCount, context.getLoginUserName(), remark, manufactureId,bean,provider);
        }else{
          	dao.updateOrderGoodsNo(new framework.core.DateUtil().getDateString(),
        			new framework.core.DateUtil().getTimeString(),sum+"",context.getLoginUserName(), remark, manufactureId);
        	dao.insertOrderDetailSignIn(new framework.core.DateUtil().getDateString(), new framework.core.DateUtil().getTimeString(),
        			allCount, currentCount, context.getLoginUserName(), remark, manufactureId,bean,provider);
        }
        
        
        aForm.getRequest().setAttribute("message", "交货确认执行成功");
        aForm.getRequest().setAttribute("backstep", "-2");
		return GSBaseConstants.FORWARD_SUCCESS;

	}
}
